#ifndef CLIENTSOCKET_H
#define CLIENTSOCKET_H

#include <QTcpSocket>
#include <QObject>
#include "tunnel_struckts.h"

class Client;
class ClientSocket : public QObject
{
    Q_OBJECT

public:
    ClientSocket(QTcpSocket *socket, Client *client);
    virtual ~ClientSocket();

    bool fillPackage(Package *package, QDataStream *incommingStream);
    void sendPackage(Package *package);

    inline QTcpSocket* getTcpSocket() { return m_socket; }

    void deleteLater();

private:
    QTcpSocket *m_socket;
    Client *m_client;
    quint16 dataSize;
    bool m_isReadingData;
    bool deleteLaterExecuted;

signals:
    void newPackage(Package *package);

private slots:
    void readSocket();
};

#endif // CLIENTSOCKET_H
